package com.staryea.hive;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

/**
 * create by gonghl
 * 2018/11/14
 */
public class HiveDAO extends AbstractDAO{

    public List<Byte[]> queryList(String sql) {
        return this.queryList(sql, convert -> {
            String text = convert.getString(1);
            String provCode = convert.getString(2);
            JSONObject jsonObject = JSONObject.parseObject(text);
            jsonObject.put("areaCode", provCode);
            return jsonObject.toJSONString().getBytes();
        });
    }

    public long queryListCount(String sql) {
        List<Long> rs = this.queryList(sql,convert -> convert.getLong(1));
        if (rs != null && rs.size() > 0) {
            return rs.get(0);
        }
        return 0L;
    }
}
